home *** CD-ROM | disk | FTP | other *** search
/ IRIX 6.5 Complementary Applications 2004 May / SGI IRIX 6.5 Complementary Applications 2004 May.iso / dist / PPRO.idb / usr / include / cups / ipp.h.z / ipp.h
Encoding:
C/C++ Source or Header  |  2004-01-20  |  12.8 KB  |  468 lines

  1. /*
  2.  * "$Id: ipp.h,v 1.47 2003/03/14 22:16:21 mike Exp $"
  3.  *
  4.  *   Internet Printing Protocol definitions for the Common UNIX Printing
  5.  *   System (CUPS).
  6.  *
  7.  *   Copyright 1997-2003 by Easy Software Products.
  8.  *
  9.  *   These coded instructions, statements, and computer programs are the
  10.  *   property of Easy Software Products and are protected by Federal
  11.  *   copyright law.  Distribution and use rights are outlined in the file
  12.  *   "LICENSE.txt" which should have been included with this file.  If this
  13.  *   file is missing or damaged please contact Easy Software Products
  14.  *   at:
  15.  *
  16.  *       Attn: CUPS Licensing Information
  17.  *       Easy Software Products
  18.  *       44141 Airport View Drive, Suite 204
  19.  *       Hollywood, Maryland 20636-3111 USA
  20.  *
  21.  *       Voice: (301) 373-9603
  22.  *       EMail: cups-info@cups.org
  23.  *         WWW: http://www.cups.org
  24.  *
  25.  *   This file is subject to the Apple OS-Developed Software exception.
  26.  */
  27.  
  28. #ifndef _CUPS_IPP_H_
  29. #  define _CUPS_IPP_H_
  30.  
  31. /*
  32.  * Include necessary headers...
  33.  */
  34.  
  35. #  include "http.h"
  36.  
  37.  
  38. /*
  39.  * C++ magic...
  40.  */
  41.  
  42. #  ifdef __cplusplus
  43. extern "C" {
  44. #  endif /* __cplusplus */
  45.  
  46.  
  47. /*
  48.  * IPP version string...
  49.  */
  50.  
  51. #  define IPP_VERSION        "\001\001"
  52.  
  53. /*
  54.  * IPP registered port number...
  55.  *
  56.  * Note: Applications should never use IPP_PORT, but instead use the
  57.  * ippPort() function to allow overrides via the IPP_PORT environment
  58.  * variable and services file if needed!
  59.  */
  60.  
  61. #  define IPP_PORT        631
  62.  
  63. /*
  64.  * Common limits...
  65.  */
  66.  
  67. #  define IPP_MAX_NAME        256
  68. #  define IPP_MAX_VALUES    10    /* Now just an allocation increment */
  69.  
  70.  
  71. /*
  72.  * Types and structures...
  73.  */
  74.  
  75. typedef enum            /**** Format tags for attribute formats... ****/
  76. {
  77.   IPP_TAG_ZERO = 0x00,
  78.   IPP_TAG_OPERATION,
  79.   IPP_TAG_JOB,
  80.   IPP_TAG_END,
  81.   IPP_TAG_PRINTER,
  82.   IPP_TAG_UNSUPPORTED_GROUP,
  83.   IPP_TAG_SUBSCRIPTION,
  84.   IPP_TAG_EVENT_NOTIFICATION,
  85.   IPP_TAG_UNSUPPORTED_VALUE = 0x10,
  86.   IPP_TAG_DEFAULT,
  87.   IPP_TAG_UNKNOWN,
  88.   IPP_TAG_NOVALUE,
  89.   IPP_TAG_NOTSETTABLE = 0x15,
  90.   IPP_TAG_DELETEATTR,
  91.   IPP_TAG_ADMINDEFINE,
  92.   IPP_TAG_INTEGER = 0x21,
  93.   IPP_TAG_BOOLEAN,
  94.   IPP_TAG_ENUM,
  95.   IPP_TAG_STRING = 0x30,
  96.   IPP_TAG_DATE,
  97.   IPP_TAG_RESOLUTION,
  98.   IPP_TAG_RANGE,
  99.   IPP_TAG_BEGIN_COLLECTION,
  100.   IPP_TAG_TEXTLANG,
  101.   IPP_TAG_NAMELANG,
  102.   IPP_TAG_END_COLLECTION,
  103.   IPP_TAG_TEXT = 0x41,
  104.   IPP_TAG_NAME,
  105.   IPP_TAG_KEYWORD = 0x44,
  106.   IPP_TAG_URI,
  107.   IPP_TAG_URISCHEME,
  108.   IPP_TAG_CHARSET,
  109.   IPP_TAG_LANGUAGE,
  110.   IPP_TAG_MIMETYPE,
  111.   IPP_TAG_MEMBERNAME,
  112.   IPP_TAG_MASK = 0x7fffffff,    /* Mask for copied attribute values */
  113.   IPP_TAG_COPY = -0x7fffffff-1    /* Bitflag for copied attribute values */
  114. } ipp_tag_t;
  115.  
  116. typedef enum            /**** Resolution units... ****/
  117. {
  118.   IPP_RES_PER_INCH = 3,
  119.   IPP_RES_PER_CM
  120. } ipp_res_t;
  121.  
  122. typedef enum            /**** Finishings... ****/
  123. {
  124.   IPP_FINISHINGS_NONE = 3,
  125.   IPP_FINISHINGS_STAPLE,
  126.   IPP_FINISHINGS_PUNCH,
  127.   IPP_FINISHINGS_COVER,
  128.   IPP_FINISHINGS_BIND,
  129.   IPP_FINISHINGS_SADDLE_STITCH,
  130.   IPP_FINISHINGS_EDGE_STITCH,
  131.   IPP_FINISHINGS_FOLD,
  132.   IPP_FINISHINGS_TRIM,
  133.   IPP_FINISHINGS_BALE,
  134.   IPP_FINISHINGS_BOOKLET_MAKER,
  135.   IPP_FINISHINGS_JOB_OFFSET,
  136.   IPP_FINISHINGS_STAPLE_TOP_LEFT = 20,
  137.   IPP_FINISHINGS_STAPLE_BOTTOM_LEFT,
  138.   IPP_FINISHINGS_STAPLE_TOP_RIGHT,
  139.   IPP_FINISHINGS_STAPLE_BOTTOM_RIGHT,
  140.   IPP_FINISHINGS_EDGE_STITCH_LEFT,
  141.   IPP_FINISHINGS_EDGE_STITCH_TOP,
  142.   IPP_FINISHINGS_EDGE_STITCH_RIGHT,
  143.   IPP_FINISHINGS_EDGE_STITCH_BOTTOM,
  144.   IPP_FINISHINGS_STAPLE_DUAL_LEFT,
  145.   IPP_FINISHINGS_STAPLE_DUAL_TOP,
  146.   IPP_FINISHINGS_STAPLE_DUAL_RIGHT,
  147.   IPP_FINISHINGS_STAPLE_DUAL_BOTTOM,
  148.   IPP_FINISHINGS_BIND_LEFT = 50,
  149.   IPP_FINISHINGS_BIND_TOP,
  150.   IPP_FINISHINGS_BIND_RIGHT,
  151.   IPP_FINISHINGS_BIND_BOTTOM
  152. } ipp_finish_t;
  153.  
  154. typedef enum            /**** Orientation... ****/
  155. {
  156.   IPP_PORTRAIT = 3,        /* No rotation */
  157.   IPP_LANDSCAPE,        /* 90 degrees counter-clockwise */
  158.   IPP_REVERSE_LANDSCAPE,    /* 90 degrees clockwise */
  159.   IPP_REVERSE_PORTRAIT        /* 180 degrees */
  160. } ipp_orient_t;
  161.  
  162. typedef enum            /**** Qualities... ****/
  163. {
  164.   IPP_QUALITY_DRAFT = 3,
  165.   IPP_QUALITY_NORMAL,
  166.   IPP_QUALITY_HIGH
  167. } ipp_quality_t;
  168.  
  169. typedef enum            /**** Job States.... */
  170. {
  171.   IPP_JOB_PENDING = 3,
  172.   IPP_JOB_HELD,
  173.   IPP_JOB_PROCESSING,
  174.   IPP_JOB_STOPPED,
  175.   IPP_JOB_CANCELLED,
  176.   IPP_JOB_ABORTED,
  177.   IPP_JOB_COMPLETED
  178. } ipp_jstate_t;
  179.  
  180. typedef enum            /**** Printer States.... */
  181. {
  182.   IPP_PRINTER_IDLE = 3,
  183.   IPP_PRINTER_PROCESSING,
  184.   IPP_PRINTER_STOPPED
  185. } ipp_pstate_t;
  186.  
  187. typedef enum            /**** IPP states... ****/
  188. {
  189.   IPP_ERROR = -1,        /* An error occurred */
  190.   IPP_IDLE,            /* Nothing is happening/request completed */
  191.   IPP_HEADER,            /* The request header needs to be sent/received */
  192.   IPP_ATTRIBUTE,        /* One or more attributes need to be sent/received */
  193.   IPP_DATA            /* IPP request data needs to be sent/received */
  194. } ipp_state_t;
  195.  
  196. typedef enum            /**** IPP operations... ****/
  197. {
  198.   IPP_PRINT_JOB = 0x0002,
  199.   IPP_PRINT_URI,
  200.   IPP_VALIDATE_JOB,
  201.   IPP_CREATE_JOB,
  202.   IPP_SEND_DOCUMENT,
  203.   IPP_SEND_URI,
  204.   IPP_CANCEL_JOB,
  205.   IPP_GET_JOB_ATTRIBUTES,
  206.   IPP_GET_JOBS,
  207.   IPP_GET_PRINTER_ATTRIBUTES,
  208.   IPP_HOLD_JOB,
  209.   IPP_RELEASE_JOB,
  210.   IPP_RESTART_JOB,
  211.   IPP_PAUSE_PRINTER = 0x0010,
  212.   IPP_RESUME_PRINTER,
  213.   IPP_PURGE_JOBS,
  214.   IPP_SET_PRINTER_ATTRIBUTES,
  215.   IPP_SET_JOB_ATTRIBUTES,
  216.   IPP_GET_PRINTER_SUPPORTED_VALUES,
  217.   IPP_CREATE_PRINTER_SUBSCRIPTION,
  218.   IPP_CREATE_JOB_SUBSCRIPTION,
  219.   IPP_GET_SUBSCRIPTION_ATTRIBUTES,
  220.   IPP_GET_SUBSCRIPTIONS,
  221.   IPP_RENEW_SUBSCRIPTION,
  222.   IPP_CANCEL_SUBSCRIPTION,
  223.   IPP_GET_NOTIFICATIONS,
  224.   IPP_SEND_NOTIFICATIONS,
  225.   IPP_GET_PRINT_SUPPORT_FILES = 0x0021,
  226.   IPP_ENABLE_PRINTER,
  227.   IPP_DISABLE_PRINTER,
  228.   IPP_PAUSE_PRINTER_AFTER_CURRENT_JOB,
  229.   IPP_HOLD_NEW_JOBS,
  230.   IPP_RELEASE_HELD_NEW_JOBS,
  231.   IPP_DEACTIVATE_PRINTER,
  232.   IPP_ACTIVATE_PRINTER,
  233.   IPP_RESTART_PRINTER,
  234.   IPP_SHUTDOWN_PRINTER,
  235.   IPP_STARTUP_PRINTER,
  236.   IPP_REPROCESS_JOB,
  237.   IPP_CANCEL_CURRENT_JOB,
  238.   IPP_SUSPEND_CURRENT_JOB,
  239.   IPP_RESUME_JOB,
  240.   IPP_PROMOTE_JOB,
  241.   IPP_SCHEDULE_JOB_AFTER,
  242.   IPP_PRIVATE = 0x4000,
  243.   CUPS_GET_DEFAULT,
  244.   CUPS_GET_PRINTERS,
  245.   CUPS_ADD_PRINTER,
  246.   CUPS_DELETE_PRINTER,
  247.   CUPS_GET_CLASSES,
  248.   CUPS_ADD_CLASS,
  249.   CUPS_DELETE_CLASS,
  250.   CUPS_ACCEPT_JOBS,
  251.   CUPS_REJECT_JOBS,
  252.   CUPS_SET_DEFAULT,
  253.   CUPS_GET_DEVICES,
  254.   CUPS_GET_PPDS,
  255.   CUPS_MOVE_JOB,
  256.   CUPS_ADD_DEVICE,
  257.   CUPS_DELETE_DEVICE
  258. } ipp_op_t;
  259.  
  260. typedef enum            /**** IPP status codes... ****/
  261. {
  262.   IPP_OK = 0x0000,
  263.   IPP_OK_SUBST,
  264.   IPP_OK_CONFLICT,
  265.   IPP_OK_IGNORED_SUBSCRIPTIONS,
  266.   IPP_OK_IGNORED_NOTIFICATIONS,
  267.   IPP_OK_TOO_MANY_EVENTS,
  268.   IPP_OK_BUT_CANCEL_SUBSCRIPTION,
  269.   IPP_REDIRECTION_OTHER_SITE = 0x300,
  270.   IPP_BAD_REQUEST = 0x0400,
  271.   IPP_FORBIDDEN,
  272.   IPP_NOT_AUTHENTICATED,
  273.   IPP_NOT_AUTHORIZED,
  274.   IPP_NOT_POSSIBLE,
  275.   IPP_TIMEOUT,
  276.   IPP_NOT_FOUND,
  277.   IPP_GONE,
  278.   IPP_REQUEST_ENTITY,
  279.   IPP_REQUEST_VALUE,
  280.   IPP_DOCUMENT_FORMAT,
  281.   IPP_ATTRIBUTES,
  282.   IPP_URI_SCHEME,
  283.   IPP_CHARSET,
  284.   IPP_CONFLICT,
  285.   IPP_COMPRESSION_NOT_SUPPORTED,
  286.   IPP_COMPRESSION_ERROR,
  287.   IPP_DOCUMENT_FORMAT_ERROR,
  288.   IPP_DOCUMENT_ACCESS_ERROR,
  289.   IPP_ATTRIBUTES_NOT_SETTABLE,
  290.   IPP_IGNORED_ALL_SUBSCRIPTIONS,
  291.   IPP_TOO_MANY_SUBSCRIPTIONS,
  292.   IPP_IGNORED_ALL_NOTIFICATIONS,
  293.   IPP_PRINT_SUPPORT_FILE_NOT_FOUND,
  294.  
  295.   IPP_INTERNAL_ERROR = 0x0500,
  296.   IPP_OPERATION_NOT_SUPPORTED,
  297.   IPP_SERVICE_UNAVAILABLE,
  298.   IPP_VERSION_NOT_SUPPORTED,
  299.   IPP_DEVICE_ERROR,
  300.   IPP_TEMPORARY_ERROR,
  301.   IPP_NOT_ACCEPTING,
  302.   IPP_PRINTER_BUSY,
  303.   IPP_ERROR_JOB_CANCELLED,
  304.   IPP_MULTIPLE_JOBS_NOT_SUPPORTED,
  305.   IPP_PRINTER_IS_DEACTIVATED
  306. } ipp_status_t;
  307.  
  308. typedef unsigned char ipp_uchar_t;/**** Unsigned 8-bit integer/character ****/
  309.  
  310. /**** New in CUPS 1.1.19 ****/
  311. typedef int    (*ipp_iocb_t)(void *, ipp_uchar_t *, int);
  312.                 /**** IPP IO Callback Function ****/
  313.  
  314. typedef union            /**** Request Header ****/
  315. {
  316.   struct            /* Any Header */
  317.   {
  318.     ipp_uchar_t    version[2];    /* Protocol version number */
  319.     int        op_status;    /* Operation ID or status code*/
  320.     int        request_id;    /* Request ID */
  321.   }        any;
  322.  
  323.   struct            /* Operation Header */
  324.   {
  325.     ipp_uchar_t    version[2];    /* Protocol version number */
  326.     ipp_op_t    operation_id;    /* Operation ID */
  327.     int        request_id;    /* Request ID */
  328.   }        op;
  329.  
  330.   struct            /* Status Header */
  331.   {
  332.     ipp_uchar_t    version[2];    /* Protocol version number */
  333.     ipp_status_t status_code;    /* Status code */
  334.     int        request_id;    /* Request ID */
  335.   }        status;
  336.  
  337.   /**** New in CUPS 1.1.19 ****/
  338.   struct            /* Event Header */
  339.   {
  340.     ipp_uchar_t    version[2];    /* Protocol version number */
  341.     int        status_code;    /* Status code */
  342.     int        request_id;    /* Request ID */
  343.   }        event;
  344. } ipp_request_t;
  345.  
  346. /**** New in CUPS 1.1.19 ****/
  347. typedef struct ipp_str ipp_t;
  348.  
  349. typedef union            /**** Attribute Value ****/
  350. {
  351.   int        integer;    /* Integer/enumerated value */
  352.  
  353.   char        boolean;    /* Boolean value */
  354.  
  355.   ipp_uchar_t    date[11];    /* Date/time value */
  356.  
  357.   struct
  358.   {
  359.     int        xres,        /* Horizontal resolution */
  360.         yres;        /* Vertical resolution */
  361.     ipp_res_t    units;        /* Resolution units */
  362.   }        resolution;    /* Resolution value */
  363.  
  364.   struct
  365.   {
  366.     int        lower,        /* Lower value */
  367.         upper;        /* Upper value */
  368.   }        range;        /* Range of integers value */
  369.  
  370.   struct
  371.   {
  372.     char    *charset;    /* Character set */
  373.     char    *text;        /* String */
  374.   }        string;        /* String with language value */
  375.  
  376.   struct
  377.   {
  378.     int        length;        /* Length of attribute */
  379.     void    *data;        /* Data in attribute */
  380.   }        unknown;    /* Unknown attribute type */
  381.  
  382. /**** New in CUPS 1.1.19 ****/
  383.   ipp_t        *collection;    /* Collection value */
  384. } ipp_value_t;
  385.  
  386. typedef struct ipp_attribute_s    /**** Attribute ****/
  387. {
  388.   struct ipp_attribute_s *next;    /* Next attribute in list */
  389.   ipp_tag_t    group_tag,    /* Job/Printer/Operation group tag */
  390.         value_tag;    /* What type of value is it? */
  391.   char        *name;        /* Name of attribute */
  392.   int        num_values;    /* Number of values */
  393.   ipp_value_t    values[1];    /* Values */
  394. } ipp_attribute_t;
  395.  
  396. struct ipp_str            /**** IPP Request/Response/Notification ****/
  397. {
  398.   ipp_state_t    state;        /* State of request */
  399.   ipp_request_t    request;    /* Request header */
  400.   ipp_attribute_t *attrs,    /* Attributes */
  401.         *last,        /* Last attribute in list */
  402.         *current;    /* Current attribute (for read/write) */
  403.   ipp_tag_t    curtag;        /* Current attribute group tag */
  404. };
  405.  
  406.  
  407. /*
  408.  * Prototypes...
  409.  */
  410.  
  411. extern ipp_attribute_t    *ippAddBoolean(ipp_t *ipp, ipp_tag_t group, const char *name, char value);
  412. extern ipp_attribute_t    *ippAddBooleans(ipp_t *ipp, ipp_tag_t group, const char *name, int num_values, const char *values);
  413. extern ipp_attribute_t    *ippAddDate(ipp_t *ipp, ipp_tag_t group, const char *name, const ipp_uchar_t *value);
  414. extern ipp_attribute_t    *ippAddInteger(ipp_t *ipp, ipp_tag_t group, ipp_tag_t type, const char *name, int value);
  415. extern ipp_attribute_t    *ippAddIntegers(ipp_t *ipp, ipp_tag_t group, ipp_tag_t type, const char *name, int num_values, const int *values);
  416. extern ipp_attribute_t    *ippAddRange(ipp_t *ipp, ipp_tag_t group, const char *name, int lower, int upper);
  417. extern ipp_attribute_t    *ippAddRanges(ipp_t *ipp, ipp_tag_t group, const char *name, int num_values, const int *lower, const int *upper);
  418. extern ipp_attribute_t    *ippAddResolution(ipp_t *ipp, ipp_tag_t group, const char *name, ipp_res_t units, int xres, int yres);
  419. extern ipp_attribute_t    *ippAddResolutions(ipp_t *ipp, ipp_tag_t group, const char *name, int num_values, ipp_res_t units, const int *xres, const int *yres);
  420. extern ipp_attribute_t    *ippAddSeparator(ipp_t *ipp);
  421. extern ipp_attribute_t    *ippAddString(ipp_t *ipp, ipp_tag_t group, ipp_tag_t type, const char *name, const char *charset, const char *value);
  422. extern ipp_attribute_t    *ippAddStrings(ipp_t *ipp, ipp_tag_t group, ipp_tag_t type, const char *name, int num_values, const char *charset, const char * const *values);
  423. extern time_t        ippDateToTime(const ipp_uchar_t *date);
  424. extern void        ippDelete(ipp_t *ipp);
  425. extern const char    *ippErrorString(ipp_status_t error);
  426. extern ipp_attribute_t    *ippFindAttribute(ipp_t *ipp, const char *name,
  427.                               ipp_tag_t type);
  428. extern ipp_attribute_t    *ippFindNextAttribute(ipp_t *ipp, const char *name,
  429.                                   ipp_tag_t type);
  430. extern size_t        ippLength(ipp_t *ipp);
  431. extern ipp_t        *ippNew(void);
  432. extern ipp_state_t    ippRead(http_t *http, ipp_t *ipp);
  433. extern const ipp_uchar_t *ippTimeToDate(time_t t);
  434. extern ipp_state_t    ippWrite(http_t *http, ipp_t *ipp);
  435. extern int        ippPort(void);
  436. extern void        ippSetPort(int p);
  437.  
  438. /**** New in CUPS 1.1.19 ****/
  439. extern ipp_attribute_t    *ippAddCollection(ipp_t *ipp, ipp_tag_t group, const char *name, ipp_t *value);
  440. extern ipp_attribute_t    *ippAddCollections(ipp_t *ipp, ipp_tag_t group, const char *name, int num_values, const ipp_t **values);
  441. extern void        ippDeleteAttribute(ipp_t *ipp, ipp_attribute_t *attr);
  442. extern ipp_state_t    ippReadFile(int fd, ipp_t *ipp);
  443. extern ipp_state_t    ippReadIO(void *src, ipp_iocb_t cb, int blocking, ipp_t *parent, ipp_t *ipp);
  444. extern ipp_state_t    ippWriteFile(int fd, ipp_t *ipp);
  445. extern ipp_state_t    ippWriteIO(void *dst, ipp_iocb_t cb, int blocking, ipp_t *parent, ipp_t *ipp);
  446.  
  447.  
  448. /*
  449.  * "Private" functions used internally by CUPS...
  450.  */
  451.  
  452. extern ipp_attribute_t    *_ipp_add_attr(ipp_t *, int);
  453. extern void        _ipp_free_attr(ipp_attribute_t *);
  454.  
  455.  
  456. /*
  457.  * C++ magic...
  458.  */
  459.  
  460. #  ifdef __cplusplus
  461. }
  462. #  endif /* __cplusplus */
  463. #endif /* !_CUPS_IPP_H_ */
  464.  
  465. /*
  466.  * End of "$Id: ipp.h,v 1.47 2003/03/14 22:16:21 mike Exp $".
  467.  */
  468.